<?php
/**
 * @version $Id: admin.nik_simplesef.php 2006-09-15 elkuku $
 * @package J!Secure
 * @copyright 
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
 */
 
defined( '_VALID_MOS' ) or die( 'Foolproofed.. !' );

// config.php
define ('NiKcfg_begin_custom', '########## Begin - NiK Custom-URLs');
define ('NiKcfg_end_custom', '########## End - NiK Custom-URLs');

// end config.inc.php

// german.php
define ('_NO_SEFS', 'Keine NiK SEFs...');
define ('_NO_HTACCESS_EDIT', '(muss zur Zeit noch &quot;h&auml;ndisch&quot; bearbeitet werden...)');
// end german.php

// db table nik_simplesef


// end db table nik_simplesef

echo '<h1>NiK_SimpleSEF</h1>';
$handle = fopen ($mosConfig_absolute_path."/.htaccess", "r");
$NiK_customStart = false;

$htOrig = array();
$htCustom = array();
$htCnt = 0;

while (!feof($handle)) {
   $buffer = fgets($handle, 4096);
   
   if ($NiK_customStart == false) {
      if (substr($buffer, 0, 34) == NiKcfg_begin_custom) {
         $NiK_customStart = true;
         echo "";
      } else {
	  	array_push ($htOrig, $buffer);
	  }
	  
   } else {
      $split = explode(" ", $buffer);
      if ($split[0] == 'RewriteRule') {
        /*echo '
        RewriteRule: <span class="rot">'
        . '<a href="'.$mosConfig_live_site.'/'.$split[1].'" target="_BLANK" class="rot">'.$split[1].'</a>'
        . '</span> - <span class="blau">'
        . $split[2]
        . '</span><br />';
        echo '
		<tr>
		 <td>
		  <a href="'.$mosConfig_live_site.'/'.$split[1].'" target="_BLANK">'.$split[1].'</a>
		 </td>
		 <td>'.$split[2].'</td>
		</tr>';*/
		//array_push ($htCustom, $split[1], $split[2]);

		$htCustom [$htCnt][0] = $split[1];
		$htCustom [$htCnt][1] = $split[2];
		$htCnt += 1;

      }
   }
}
echo '</table>';
fclose ($handle);

if ($NiK_customStart == false) {
	echo '<h1>'._NO_SEFS.'</h1>';
} else {
	echo '<h2>Custom RewriteRules</h2>';
	echo '<table border="1" cellpadding="5">';
	for ($i=0; $i<=$htCnt-1; $i++)
	{
	  echo '<tr><td>
	  <a href="'.$mosConfig_live_site.'/'.$htCustom [$i][0] . '" target="_BLANK">'.$htCustom [$i][0] .'</a>
	  </td><td>' . $htCustom [$i][1] . '</td></tr>';
	}
	echo '</table>';
}
echo '<hr />';
echo '<h2>.htaccess ohne Custom URLs</h2>
<small>' . _NO_HTACCESS_EDIT . '</small><br />
<div align="left">';
foreach ($htOrig as $line) {
	echo $line . '<br />';
}
echo '</div>';

echo '<hr />
<div align="center">by <a href="http://www.nik-it.de">NiK-IT.de</a> 2007</div>
<hr />';
?>